package com.example.spring_boot.controller;

import com.example.spring_boot.bean.Dog;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DogController {
    @Autowired
    private ApplicationContext applicationContext;
    @Resource(name = "singletonDog")
    private Dog singletonDog;
    @RequestMapping("/singleonDog")
        public String singleonDog(){
        Dog dog1=(Dog)applicationContext.getBean("singletonDog");
        return ("ResourceDog:"+singletonDog+"ContextDog"+dog1);
    }
    @Resource(name = "prototypeDog")
    private Dog prototypeDog;
    @RequestMapping("/prototypeDog")
    public String prototypeDog(){
        Dog dog1=(Dog)applicationContext.getBean("prototypeDog");
        return ("ResourceDog:"+prototypeDog+"ContextDog"+dog1);
    }
    @Resource(name = "requestDog")
    private Dog requestDog;
    @RequestMapping("/requestDog")
    public String requestDog(){
        Dog dog1=(Dog)applicationContext.getBean("requestDog");
        return ("ResourceDog:"+requestDog+"ContextDog"+dog1);
    }

    @Resource(name = "sessionDog")
    private Dog sessionDog;
    @RequestMapping("/sessionDog")
    public String sessionDog(){
        Dog dog1=(Dog)applicationContext.getBean("sessionDog");
        return ("ResourceDog:"+sessionDog+"ContextDog"+dog1);
    }
    @Resource(name = "ApplicationDog")
    private Dog ApplicationDog;
    @RequestMapping("/ApplicationDog")
    public String ApplicationDog(){
        Dog dog1=(Dog)applicationContext.getBean("ApplicationDog");
        return ("ResourceDog:"+ApplicationDog+"ContextDog"+dog1);
    }


}
